<?php
$this->headTitle('Quản Lý Thiết Bị Tự Do','append');
?>
<div class="grid grid_7">
    <div class="box-header">
        <a class="add" href="<?php echo $this->url(array ('controller' => 'item' ,'action' => 'add-item'));?>">Thêm mới</a>
    </div>
    <div class="box">
        <?php
            $session_check = new Zend_Session_Namespace('Check'); 
            if(isset($session_check->status))
            {
                echo '<div class="notification success">',$session_check->status,'</div>';
            }
            if(isset($this->mess)){
                if($this->flag == 'success')
                    echo '<div class="notification success">',$this->mess,'</div>';
                else
                    echo '<div class="notification error">',$this->mess,'</div>';
            }
            else
            {
        ?>
	  
         <table cellspacing="0" class="content_equipment">
            	<thead id="detail">
        		<tr>
  		            <td>Mã Item</td>
                    <td>Tên</td>
                   	<td>Serial Number</td>
        			<td>Giá Mua</td>
                    <td>Giá Thuê</td>
        			<td>Giá Hiện Tại</td>
                    <td>Giá Sau Hợp Đồng</td>
        			<td>Ngày Bắt Đầu</td>
                    <td>Ngày Kết Thúc</td>
        			<td>Tài Sản</td>
                    <td>Người Kí HD</td>
                    <td>Thông Tin</td>
                    <td>Lịch Sử</td>
        		
        			<td>Tuỳ chọn</td>
        		</tr>
        	</thead>
            <tbody>
            <?php
            foreach($this->itemList as $item){ ?>
                <tr>
            <?php
                if(isset($item['itemId']))
                    echo '<td>
                            <span title="',str_replace('"',"'",$item['itemId']),'">',
                            $item['itemId'] ? $this->stringTrim(str_replace("\r\n","",$item['itemId']), 40) : '-','
                            </span>
                         </td>'; 
                if(isset($item['itemName']))
                    echo '<td>
                            <span title="',str_replace('"',"'",$item['itemName']),'">',
                            $item['itemName'] ? $this->stringTrim(str_replace("\r\n","",$item['itemName']), 40) : '-','
                            </span>
                        </td>'; 
                 if(isset($item['serialNumber']))
                    echo '<td>
                            <span title="',str_replace('"',"'",$item['serialNumber']),'">',
                            $item['serialNumber'] ? $this->stringTrim(str_replace("\r\n","",$item['serialNumber']), 40) : '-','
                            </span>
                         </td>';
                if(isset($item['priceItem']))
                    echo '<td>
                           <span title="',$item['priceItem'] ? number_format($item['priceItem'], 0, ',', '.') : '0','">',
                                            $item['priceItem'] ? number_format($item['priceItem'], 0, ',', '.') : '0','
                           </span>
                        </td>'; 
                if(isset($item['rentItem']))
                    echo '<td>
                           <span title="',$item['rentItem'] ? number_format($item['rentItem'], 0, ',', '.') : '0','">',
                                            $item['rentItem'] ? number_format($item['rentItem'], 0, ',', '.') : '0','
                           </span>
                        </td>'; 
                if(isset($item['priceNow']))
                    echo '<td>
                           <span title="',$item['priceNow'] ? number_format($item['priceNow'], 0, ',', '.') : '-0','">',
                                            $item['priceNow'] ? number_format($item['priceNow'], 0, ',', '.') : '0','
                           </span>
                        </td>'; 
                 if(isset($item['rentEnd']))
                    echo '<td>
                           <span title="',$item['rentEnd'] ? number_format($item['rentEnd'], 0, ',', '.') : '-0','">',
                                            $item['rentEnd'] ? number_format($item['rentEnd'], 0, ',', '.') : '0','
                           </span>
                        </td>';
                 if(isset($item['startDate']))
                    echo '<td>
                           <span title="',$item['startDate'] ? $this->time()->dataToDate($item['startDate']) : '-','">',
                             $item['startDate'] ? $this->time()->dataToDate($item['startDate']) : '-','
                           </span>
                        </td>';  
                  if(isset($item['duration']))
                    echo '<td>
                           <span title="',$item['duration'] ? $this->time()->dataToDate($item['duration']) : '-','">',
                             $item['duration'] ? $this->time()->dataToDate($item['duration']) : '-','
                           </span>
                        </td>'; 
                  if(isset($item['owner']))
                    echo '<td>
                            <span title="',str_replace('"',"'",$item['owner']),'">',
                            $item['owner'] ? $this->stringTrim(str_replace("\r\n","",$item['owner']), 40) : '-','
                            </span>
                         </td>';  
                  if(isset($item['holders']))
                    echo '<td>
                            <span title="',str_replace('"',"'",$item['holders']),'">',
                            $item['holders'] ? $this->stringTrim(str_replace("\r\n","",$item['holders']), 40) : '-','
                            </span>
                         </td>';  
                  if(isset($item['info']))
                    echo '<td>
                            <span title="',str_replace('"',"'",$item['info']),'">',
                            $item['info'] ? $this->stringTrim(str_replace("\r\n","",$item['info']), 40) : '-','
                            </span>
                         </td>';  
                  if(isset($item['history']))
                    echo '<td>
                            <span title="',str_replace('"',"'",$item['history']),'">',
                            $item['history'] ? $this->stringTrim(str_replace("\r\n","",$item['history']), 40) : '-','
                            </span>
                         </td>'; 
                   
               ?>          
                  <td style="border-right: 1px solid #CCCCCC; ">
                      <a class="fancybox" href="http://local.cmdb.ssgroup.com.vn/equipment/search/mul/1/id/<?php echo $item['itemId']?>">
                          <img src="image/icons/small/icon_Tools_16.png" title="Gắn vào thiết bị" style=" width: 18px;height: 18px;"/>
                      </a>
                      <a href="<?php echo $this->url(array ( 'controller' => 'item' ,'action' => 'edit' , 'id' => $item['itemId'] )); ?>">
                          <img src="image/icons/small/icon_edit.png" title="Sửa Thiết Bị" style=" width: 18px;height: 18px; position: relative;  "/>
                 	  </a>
                       <a href="<?php echo $this->url(array ( 'controller' => 'item' ,'action' => 'delete' , 'id' => $item['itemId'] )); ?>">
                          <img src="image/icons/small/icon_delete.png" title="Xóa Thiết Bị" style=" width: 18px;height: 18px; position: relative;  "/>
                      </a>
                  </td>
            <?php } ?>
                
            </tr>
            </tbody>
             <tfoot>
        		<tr>
        			<td colspan="<?php echo count($this->arr_header)+5?>">
        				<div class="container">
        					<div class="pagination">
        						<?php
        							echo $this->paginationControl($this->panigator,'Sliding','paginator.phtml');
        						?>
        					</div>
        				</div>
        			</td>
        		</tr>
        	  </tfoot>
       </table>
    
    
    </div>
    <?php } ?>
</div>

<script type="text/javascript">
        $('a.fancybox').fancybox({
            'width'             : 1200,
            'height'            : 'auto',
            'type'              : 'iframe'
           
           
        });
    </script>
    
